package rsj.service.stat.dynamic;

import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 统计动态sql
 *
 * @author yuanqinglong
 * @since 2021/8/4 15:37
 */
@Component
public class StatDynamicStatement {


    /**
     * 统计合同使用
     *
     * @param orgpIds 合同id
     * @return {@link String}
     */
    public String statisticContractUsage(List<String> orgpIds){
        return "SELECT stat_orgp_id,\n" +
                "       stat_prod_uid,\n" +
                "       SUM(stat_req_num) AS stat_req_num,\n" +
                "       SUM(stat_findout_num) AS stat_findout_num,\n" +
                "       SUM(stat_null_num) AS stat_null_num,\n" +
                "       SUM(stat_fail_num) AS stat_fail_num,\n" +
                "       SUM(stat_charge_num) AS stat_charge_num,\n" +
                "       SUM(stat_up_useamount) AS stat_up_useamount\n" +
                "FROM sys.sys_stat WHERE stat_orgp_id IN (#{orgpIds}) GROUP BY stat_orgp_id , stat_prod_uid";
    }
}
